package com.itheima.web; /**
 * @author Xiao
 * @date 2021/8/31
 */

import com.itheima.pojo.Brand;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/jsp03")
public class JSPServlet03 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        //准备数据
        List<Brand> list = new ArrayList<>();
        list.add(new Brand(1, "三只松鼠", "三只松鼠", 100, "三只松鼠，好吃不上火", 1));
        list.add(new Brand(2,"优衣库","优衣库",200,"优衣库，服适人生",0));
        list.add(new Brand(3,"小米","小米科技有限公司",1000,"为发烧而生",1));
        //封装数据到request域对象
        request.setAttribute("brands", list);
        //传递数据到jsp03.jsp页面
        request.getRequestDispatcher("/jsp03.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
